package com.sxbbc.common.core.enums;

import com.sxbbc.common.basics.utils.calculation.CalcuUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author leehao
 * @description solr排序类型
 * @date 2019-06-04
 */
public enum SolrSortEnums {
    NORMAL(0,"默认"),
    PRICE(1,"价格"),
    SALE_NUMS(2,"销量"),
    NEW_PRODUCT(3, "新品"),
    POINT(4, "积分");

    private Integer id;
    private String name;

    SolrSortEnums(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static List<SolrSortEnums> queryList() {
        List<SolrSortEnums> list = new ArrayList<SolrSortEnums>();
        for (SolrSortEnums o : SolrSortEnums.values()) {
            list.add(o);
        }
        return list;
    }

    public static String getName(Integer id) {
        String str = "";
        for (SolrSortEnums o : SolrSortEnums.values()) {
            if (CalcuUtils.getInstance().isEquals(id, o.getId())) {
                str = o.getName();
                break;
            }
        }
        return str;
    }
}
